package com.gitee.shigen.controller;

import com.gitee.shigen.annotation.Master;
import com.gitee.shigen.entity.User;
import com.gitee.shigen.service.UserService;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author shigenfu
 * @date 2023/10/28 13:48
 */
@RestController
@RequestMapping(value = "user")
public class UserController {

    @Resource
    private UserService userService;

    @GetMapping(value = "{id}")
    public User getUserById(@PathVariable("id") Integer id) {
        return userService.getById(id);
    }

    @GetMapping(value = "list")
    @Master
    public List<User> getUserList() {
        return userService.list();
    }

    @GetMapping
    public boolean insert(User user) {
        return userService.save(user);
    }
}
